home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / daymisckit_proj / Headers / daymisckit / DAYLogFile.h < prev    next >
Text File  |  1995-06-12  |  2KB  |  71 lines

  1. //
  2. //    DAYLogFile.h -- a generic class to simplify keeping an atomic lock file
  3. //        Written by Don Yacktman (c) 1993 by Don Yacktman.
  4. //                Version 1.0.  All rights reserved.
  5. //
  6. //        This is a free object!  Contact the author for the latest version.
  7. //        Don Yacktman, 4279 N. Ivy Lane, Provo, UT, 84604
  8. //        e-mail:  Don_Yacktman@byu.edu
  9. //
  10. //    See DAYLogFile.m for details of the software license.
  11. //
  12.  
  13. #import <appkit/appkit.h>
  14.  
  15. @interface DAYLogFile:Object <NXTransport>
  16. {
  17.     id lockFile, fileName, lastLine;
  18.     int repeats;
  19.     BOOL fileOpen, special; // special == YES if using stdout or stderr
  20.     FILE *file;        // only valid if fileOpen == YES
  21. }
  22.  
  23. - init;
  24. - fileName;
  25.  
  26. // Changing the name of the file will close the current log, if open,
  27. // and stop using a lock file (see below).  Pass in a DAYString for
  28. // the file name.
  29. - setFileName:aString;
  30.  
  31. // If you pass in a DAYLockFile, then the log file will be locked
  32. // by using the DAYLockFile you passed in.  If more than one process
  33. // can affect a log file, then you should make sure that all those
  34. // processes use a lock file!  If you don't set up a lock file,
  35. // then by default none will be used.
  36. - setLockFile:newLockFile;
  37.  
  38. // Use this method to add an arbitrary string to the log file --
  39. // it opens and closes the file automatically, obtaining locks if needed.
  40. // This is better than sitting for a long time holding locks.
  41. // returns YES is successful, NO otherwise.
  42. - (BOOL)addLineToLogFile:aString;
  43.  
  44. // These are for use when you have multiple things to add and you wish to
  45. // keep the file open until you are done writing all of it.  Function is
  46. // rather obvious.  Return YES if successful, no otherwise.
  47. - (BOOL)openFile;    // always opened for APPENDING.  Created if non-existent.
  48. - (BOOL)appendToLogFile:aString andFlush:(BOOL)flushFlag;
  49. - (BOOL)closeFile;
  50.  
  51. // -openFile and -closeFile have no effect if you use these:
  52. - usestdout;
  53. - usestderr;
  54.  
  55. // These are pretty obvious.  A copy will not be an opened file nor will it
  56. // have a lock, regardless of the state of the receiver of the -copy.
  57. - copy;
  58. - read:(NXTypedStream *)stream;
  59. - write:(NXTypedStream *)stream;
  60.  
  61. // Use these if you must...
  62. - (FILE *)file;
  63. - (BOOL)fileIsOpen;
  64. - (BOOL)special;
  65. - lockFile;
  66.  
  67. // Handles closing files and removing locks if necessary.
  68. - free;
  69.  
  70. @end
  71.